﻿using Orchard.Data.Migration;
using Orchard.Environment.Extensions;
using System.Data;

namespace Rework.CommerceHistory.Migrations {
    [OrchardFeature("Rework.CommercePayPal")]
    public class CommercePayPalMigrations : DataMigrationImpl {
        public int Create() {
            SchemaBuilder.CreateTable("CommercePayPalSettingsPartRecord", table => table
				.ContentPartRecord()
				.Column("BusinessEmailAddress", DbType.String)
				.Column("MerchantId", DbType.String)
				.Column("PDTAuthenticationToken", DbType.String)
				.Column("IsSandbox", DbType.Boolean)
                .Column("RecipientsUserName", DbType.String)
                .Column("Currency", DbType.String, c => c.WithDefault("USD"))
                .Column("WeightUnit", DbType.String, c => c.WithDefault("LB"))
			);
            return 1;
        }

        public int UpdateFrom1() {
            SchemaBuilder.AlterTable("CommercePayPalSettingsPartRecord", table => table
                .DropColumn("RecipientsUserName"));
            return 2;
        }
    }
}
